import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_class2/3681/AboutPage.dart';
import 'package:flutter_class2/3681/accountRelated/ChangeAccountPage.dart';
import 'package:flutter_class2/5778/Home.dart';
import 'package:shake_animation_widget/shake_animation_widget.dart';

import '1195/login.dart';
import '3681/LoginPage.dart';
import '5778/LoginScreen.dart';
import 'common/global.dart';
import 'mCard.dart';

void main() {
  Global.init();//启动应用时就要初始化的全局变量
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  String wid_test = '蛮大的新闻';
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: wid_test,
      theme: ThemeData(
        primaryColor: Colors.white,
      ),
      routes:{
        /*------将 你 的 页 面 名 称 填 至 此 处 空 白 ！------*/
        '/ccb':(BuildContext context) => ccb_loginPage(),
        '/meng':(BuildContext context) => LoginPage(),
        '/adu':(BuildContext context) => AduLogin(),
        '/adu_0':(BuildContext context) => Home(),
        '/test':(BuildContext context) => null,
        '/changeAccount':(BuildContext context) => ChangeAccountPage(),
        '/mengIntroduction':(BuildContext context) => AboutPage(),
      },
      home: MyHomePage(title: 'Group 10'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {

    Global.screenWidth = MediaQuery.of(context).size.width; // 获取屏幕大小并用作全局变量

    //初始化组件颤抖效果的控制器
    ShakeAnimationController _shakeAnimationController_0 =  new ShakeAnimationController();
    ShakeAnimationController _shakeAnimationController_1 =  new ShakeAnimationController();
    ShakeAnimationController _shakeAnimationController_2 =  new ShakeAnimationController();

    final mCardOfccb = ShakeAnimationWidget(
      shakeAnimationController: _shakeAnimationController_0,
      shakeAnimationType: ShakeAnimationType.SkewShake,
      isForward: false,
      shakeCount: 1,
      shakeRange: 0.06,
      child: Container(
        padding: EdgeInsets.fromLTRB(50, 25, 50, 25),
        width: MediaQuery.of(context).size.width, // 用于填满父布局，或者double.infinity
        child:InkWell(
          child: mCard(MediaQuery.of(context).size.width, 'images/ccb.png', "5120181195", "菜菜博带飞 \n✈ 芜湖 ✈"),
          onTap: (){
            if (_shakeAnimationController_0.animationRunging) {
              _shakeAnimationController_0.stop();
            } else {
              _shakeAnimationController_0.start(shakeCount: 1);
            }
            Navigator.pushNamed(context, '/ccb');
          },
        ),
      ),
    );

    final mCardOfmeng = ShakeAnimationWidget(
      ///绑定抖动控制器
      shakeAnimationController: _shakeAnimationController_1,
      ///微旋转的抖动
      shakeAnimationType: ShakeAnimationType.SkewShake,
      ///设置是否开启抖动
      isForward: false,
      ///默认为 0 无限执行
      shakeCount: 1,
      ///抖动的幅度 取值范围为[0,1]
      shakeRange: 0.06,
      ///执行抖动动画的子Widget
      child: Container(
        padding: EdgeInsets.fromLTRB(50, 25, 50, 25),
        width: MediaQuery.of(context).size.width,
        child:InkWell(
          child: mCard(MediaQuery.of(context).size.width, 'images/meng.png', "5120183681计科1802", "混就完事儿了\n( •̀ ω •́ )✧ 。。。。。。。。"),
          onTap: (){
            ///判断抖动动画是否正在执行
            if (_shakeAnimationController_1.animationRunging) {
              ///停止抖动动画
              _shakeAnimationController_1.stop();
            } else {
              ///开启抖动动画
              ///参数shakeCount 用来配置抖动次数
              ///通过 controller start 方法默认为 1
              _shakeAnimationController_1.start(shakeCount: 1);
            }
            Navigator.pushNamed(context, '/meng');
          },
        ),
      ),
    );

    final mCardOfadu = ShakeAnimationWidget(
      shakeAnimationController: _shakeAnimationController_2,
      shakeAnimationType: ShakeAnimationType.SkewShake,
      isForward: false,
      shakeCount: 1,
      shakeRange: 0.06,
      child: Container(
        padding: EdgeInsets.fromLTRB(50, 25, 50, 25),
        width: MediaQuery.of(context).size.width, // 用于填满父布局，或者double.infinity
        child:InkWell(
          child: mCard(MediaQuery.of(context).size.width, 'images/adu.png', "5120185778", "赌王不得house"),
          onTap: (){
            if (_shakeAnimationController_2.animationRunging) {
              _shakeAnimationController_2.stop();
            } else {
              _shakeAnimationController_2.start(shakeCount: 1);
            }
            Navigator.pushNamed(context, '/adu');
          },
        ),
      ),
    );



    return Scaffold(
      appBar: AppBar(
        title: Center(child: Text(widget.title),),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            mCardOfccb,
            mCardOfmeng,
            mCardOfadu
          ],
        ),
      ),
    );

  }

}


